package com.uchedao.seller.module;

import android.text.TextUtils;

import com.google.gson.Gson;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

/**
 * 附加信息
 * Created by hang on 2015/10/25.
 */
public class AttachInfo implements Cloneable {

    @Expose
    @SerializedName("naked_car_price")
    public String naked_car_price;// 裸车价

    @Expose
    @SerializedName("full_car_price")
    public String full_car_price;// 购车全款

    @Expose
    @SerializedName("invoice_key")
    public String invoice_key = "0";// 发票

    @Expose
    @SerializedName("invoice")
    public String invoice;// 发票

    @Expose
    @SerializedName("config_form_key")
    public String config_form_key = "0";// 配置单

    @Expose
    @SerializedName("config_form")
    public String config_form;// 配置单(有、无)

    @Expose
    @SerializedName("config_form_path")
    public String config_form_path;// 配置单图片

    @Expose
    @SerializedName("config_form_url")
    public String config_form_url;// 配置单图片

    @Override
    public AttachInfo clone() throws CloneNotSupportedException {
        return (AttachInfo) super.clone();
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        AttachInfo info = getClass().cast(obj);
        return info.toString().equals(toString());
    }

    public String toString() {
        return new Gson().toJson(this);
    }

    /**
     * 信息完成状态  0未开始，1进行中，2已完成
     */
    public int getStatus() {
        String[] datas = {naked_car_price, full_car_price, invoice, config_form};
        for(int i=0; i<datas.length; i++)
            if(TextUtils.isEmpty(datas[i]))
                return 1;

        if("有".equals(config_form) && TextUtils.isEmpty(config_form_path))
            return 1;

        return 2;
    }
}
